package org.springframework.beans;

import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Compenent;

/**
 * @Name Person
 * @Description: Bean 测试类
 * @Version v1.0.0
 * @Author: lichao
 * @Date: 2024-03-15 14:25:03
 **/
@Compenent
public class Person implements InitializingBean, DisposableBean {
    private String name;
    private int age;
    @Autowired
    private Car car;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Car getCar() {
        return car;
    }

    public void setCar(Car car) {
        this.car = car;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", car=" + car +
                '}';
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("执行实现了 InitializingBean 接口的初始化方法... ...");
    }

    public void customInitMethod() {
        System.out.println("执行在 Xml 配置文件中指定的自定义的初始化方法... ...");
    }

    @Override
    public void destory() throws Exception {
        System.out.println("执行实现了 DisposableBean 接口的销毁方法... ...");
    }

    public void customDestoryMethod() {
        System.out.println("执行在 Xml 配置文件中指定的自定义的销毁方法... ...");
    }

}

